package my_test.utils;


import my_test.service.impl.AppUserDetailsImpl;
import org.springframework.security.authentication.dao.ReflectionSaltSource;
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;

/**
 * Created by kevin on 16-9-18.
 */
public class PasswordGenerator {
    public static void main (String[] args) {
        Md5PasswordEncoder md5PasswordEncoder = new Md5PasswordEncoder();

        String username = "name-oVc0juEi05avg0aAIqf0uwLO8BqM";
        String password = "";

        ReflectionSaltSource saltSource = new ReflectionSaltSource();
        saltSource.setUserPropertyToUse("username");

        AppUserDetailsImpl userDetails = new AppUserDetailsImpl();
        userDetails.setUsername(username);

        String encodedPassword = md5PasswordEncoder.encodePassword(password, saltSource.getSalt(userDetails));

        System.out.println(username);
        System.out.println(encodedPassword);
    }
}
